<template>
    <div>
        <Card :bordered="false" dis-hover class="ivu-mt">
             <Row :gutter="16">
                <Form :model="formInline">
                <Col span="4"><Input type="text" placeholder="请输入姓名/电话" /></Col>
                <Col span="4">
                    <Select v-model="formInline.project" placeholder="请选择项目" clearable >
                        <Option value="华研">华研</Option>
                        <Option value="北大">北大</Option>
                        <Option value="长沙">长沙</Option>
                    </Select>
               </Col>
            <Col span="16" class="ivu-text-right"><Button type="primary" @click="handleCreate">新增</Button>
            <Button type="success" @click="handleUpdate" class="ivu-ml-8">同步钉钉</Button>
            </Col>
            </Form>
            </Row>
            <Table highlight-row :columns="columns" :data="data" class="ivu-mt-16">
                <template slot-scope="{ row }" slot="status">
                    <Badge v-if="row.status ==='1'" status="success" text="正常" />
                    <Badge v-if="row.status ==='0'" status="error" text="停用" />
                </template>
                <template slot-scope="{ row }" slot="operation">
                    <a @click="handleEdit">编辑</a>
                </template>
            </Table>
            <div class="ivu-mt iuv-text-center">
                <Page :total="100" show-total />
            </div>
        </Card>
        <Modal
            v-model="modal"
            :title="person ? '新增' : '编辑'"
            width="800"
            @on-ok="handleSubmit"
            @on-cancel="handleDrawerCancel"
        >
            <Form :model="formItem" :label-width="80">
                <Row :gutter="12">
                    <Col span="12">
                        <FormItem label="姓名" required>
                            <Input v-model="formItem.input" placeholder="请输入"></Input>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="手机号" required>
                            <Input v-model="formItem.phone" placeholder="请输入"></Input>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="项目" required>
                            <Select v-model="formItem.project" multiple>
                                <Option value="合肥北大">合肥北大</Option>
                                <Option value="华研">华研</Option>
                                <Option value="南通">南通</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="帐号">
                            <Input disabled="disabled" v-model="formItem.accounts" placeholder="手机号"></Input>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="密码">
                            <Input v-model="formItem.password" placeholder="请输入"></Input>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="确认密码">
                            <Input v-model="formItem.confirm" placeholder="请输入"></Input>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="状态">
                            <i-switch v-model="formItem.switch">
                                <span slot="open">On</span>
                                <span slot="close">Off</span>
                            </i-switch>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        </Modal>
    </div>
</template>

<script>
    export default {
        name: 'diagnosis',
        data () {
            return {
                modal: false,
                person: true,
                formInline: {
                    post: '',
                    role: '',
                    room: '',
                    department: '',
                    project: ''
                },
                formItem: {
                    input: '',
                    phone: '',
                    gender: '',
                    post: '',
                    role: '',
                    room: '',
                    accounts: '',
                    password: '',
                    confirm: '',
                    project: '',
                    switch: true
                },
                formItem1: {
                    interset: ''
                },
                columns: [
                    {
                        title: '名称',
                        key: 'name'
                    },
                    {
                        title: '手机号',
                        key: 'phone'
                    },
                    {
                        title: '项目',
                        key: 'project'
                    },
                    {
                        title: '最后登录时间',
                        key: 'lastLoginTime'
                    },
                    {
                        title: '状态',
                        slot: 'status'
                    },
                    {
                        title: '操作',
                        slot: 'operation'
                    }
                ],
                data: [
                    {
                        name: '王艳',
                        phone: '13588685658',
                        project: '合肥北大',
                        lastLoginTime: '2020-05-06 17:01',
                        role: '项目负责人',
                        status: '0'
                    },
                    {
                        name: '高玲',
                        phone: '18988685658',
                        project: '合肥华研',
                        lastLoginTime: '2020-05-06 18:01',
                        role: '客服',
                        status: '1'
                    }
                ]
            }
        },
        methods: {
            handleCreate () {
                this.modal = true;
                this.person = true;
            },
            handleEdit () {
                this.person = false;
                this.modal = true;
            },
            handleDrawerCancel () {
                this.$Message.warning('已取消!');
            },
            handleSubmit () {
                this.$Message.success('操作成功!');
            },
            handleUpdate () {
                this.$Modal.info({
                    title: '钉钉同步',
                    content: '数据同步中，请稍等'
                })
            }
        }
    }
</script>

<style scoped>
</style>
